package com.lovo.controller;

import com.lovo.model.DTO.ClassDTO;
import com.lovo.result.ResponseResult;
import com.lovo.service.ClassService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@ResponseResult
@RequestMapping("/class")
public class ClassController {
    @Resource
    private ClassService classService;

    @GetMapping("/{id}")
    public Object findById(@PathVariable("id") Integer id) {
        return classService.findById(id);
    }

    ;

    @PostMapping
    public Object add(@RequestBody ClassDTO classDTO) {
        classService.add(classDTO);
        return null;
    }

    ;

    @DeleteMapping("/{id}")
    public Object del(@PathVariable("id") Integer id) {
        classService.del(id);
        return null;
    }

    ;

    @PutMapping("/{id}")
    public Object update(@PathVariable("id") Integer id, @RequestBody ClassDTO classDTO) {
        classService.update(id, classDTO);
        return null;
    }

}
